<template>
    <view class="page">
        <view class="container">
            <view class="boxsty" v-for="(item,index) in list" @click="clickHandler(index)" :key="index">

                <u-row justify="space-between">
                    <view class="_titles">
                        {{item.msg_title}}
                    </view>
                    <u-badge :isDot="parseInt(item.is_read)===0" type="error"></u-badge>
                </u-row>
                <view class="_titme">
                    {{item.msg_ctime}}
                </view>
                <view class="_titme">
                    {{item.msg_text}}
                </view>

            </view>
        </view>
    </view>
</template>

<script>
    export default {
        name: "sale",
        data() {
            return {
                // list:[
                //     {isDot: true},
                //     {isDot: true},
                //     {isDot: true},
                // ]
                list:[],
            };
        },
        onLoad(){
            let url = '/api.php/house/message_list' + uni.$u.queryParams({type: 2, u_id: uni.getStorageSync('u_id')});
            uni.showLoading({title: '正在加载'});
            uni.$u.http.get(url).then(res => {
                uni.hideLoading();
                this.list = res;
            });
        },
        methods:{
            clickHandler(index){
                this.list[index].is_read = 1;

                let u_id = uni.getStorageSync('u_id');
                let url = '/api.php/House/mess_read' + uni.$u.queryParams({msg_id: this.list[index].id, u_id: u_id});
                uni.$u.http.get(url).then(res => {});
            },

        }
    }
</script>

<style lang="scss" scoped>
    .pages {
        width: 100%;
        min-height: 100vh;
        background-color: RGBA(245, 245, 245, 1);
    }

    .container{
        padding: 20rpx;
        .boxsty{
            width: 100%;
            height: 280rpx;
            margin-top: 20rpx;
            padding-top: 10rpx;
            border-bottom: 1px solid #c0c4cc;
            ._titme{
                color: #b4b4b4;
                margin-top: 20rpx;
            }
            ._titles{
                font-size: 18px;
                font-weight: bold;
            }
        }
    }
</style>